// token的生成与解析
const jwt = require('jsonwebtoken')
const { auth } = require('../env')

const { privateKey, publicKey, expiresIn } = auth

const tokenGenerator = (payload) => {
    const result = jwt.sign(payload, privateKey, {
        expiresIn,
        algorithm: 'RS256'
    })
    return result
}

const tokenResolver = (token) => {
  const result = jwt.verify(token, publicKey, { algorithm: 'RS256' })
  return result
}

module.exports = {
  tokenGenerator,
  tokenResolver,
}
// lys分支测试
